/**
 * 
 */
package com.sx.feesunit.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.sx.core.BaseDao;
import com.sx.feesunit.dao.IAreaDao;
import com.sx.feesunit.entity.AreaEntity;

/**
 * @author Administrator
 *
 */
public class AreaDao extends BaseDao implements IAreaDao {
	private Log log = LogFactory.getLog(this.getClass());
	/**
	 *findTop10AreaUsers 
	 **/
	public List<AreaEntity> findTop10AreaUsers(AreaEntity area) throws Exception{
		List<AreaEntity> list = new ArrayList<AreaEntity>();
		try {
			list = super.getSqlMapClientTemplate().queryForList("Area.findTop10AreaUsers",area);
		} catch (Exception e) {
			log.error("分析小区信息失败",e);
		}
		return list;
	}
	/* (non-Javadoc)
	 * @see com.sx.feesunit.dao.IAreaDao#addAreaInfo(com.sx.feesunit.entity.AreaEntity)
	 */
	public Integer addAreaInfo(AreaEntity area) throws Exception {
		try {
			return super.addInfo(area, "Area.addAreaInfo");
		} catch (Exception e) {
			// TODO: handle exception
			log.error("新增小区失败",e);
			return new Integer(0);
		}
	}

	/* (non-Javadoc)
	 * @see com.sx.feesunit.dao.IAreaDao#deleteAreaInfo(com.sx.feesunit.entity.AreaEntity)
	 */
	public boolean deleteAreaInfo(AreaEntity area) throws Exception {
		try {
			return super.delInfo(area, "Area.deleteAreaInfo");
		} catch (Exception e) {
			// TODO: handle exception
			log.error("删除小区失败",e);
			return false;
		}
	}

	/* (non-Javadoc)
	 * @see com.sx.feesunit.dao.IAreaDao#findAreaInfo(com.sx.feesunit.entity.AreaEntity)
	 */
	public List<AreaEntity> findAreaInfo(AreaEntity area) throws Exception {
		List<AreaEntity> list = new ArrayList<AreaEntity>();
		try {
			list = super.getSqlMapClientTemplate().queryForList("Area.findAreaInfo",area);
		} catch (Exception e) {
			log.error("查询小区失败",e);
		}
		return list;
	}
 
	/* (non-Javadoc)
	 * @see com.sx.feesunit.dao.IAreaDao#findAreaInfoByAndCondiction(com.sx.feesunit.entity.AreaEntity)
	 */
	public List<AreaEntity> findAreaInfoByAndCondiction(AreaEntity area)
			throws Exception {
		List<AreaEntity> list = new ArrayList<AreaEntity>();
		try {
			list = super.getSqlMapClientTemplate().queryForList("Area.findAreaInfoByAndCondiction",area);
		} catch (Exception e) {
			log.error("分页查询小区And连接失败",e);
		}
		return list;
	}

	/* (non-Javadoc)
	 * @see com.sx.feesunit.dao.IAreaDao#findAreaInfoByOrCondiction(com.sx.feesunit.entity.AreaEntity)
	 */
	public List<AreaEntity> findAreaInfoByOrCondiction(AreaEntity area)
			throws Exception {
		List<AreaEntity> list = new ArrayList<AreaEntity>();
		try {
			list = super.getSqlMapClientTemplate().queryForList("Area.findAreaInfoByOrCondiction",area);
		} catch (Exception e) {
			log.error("分页查询小区Or连接失败",e);
		}
		return list;
	}

	/* (non-Javadoc)
	 * @see com.sx.feesunit.dao.IAreaDao#updateAreaInfo(com.sx.feesunit.entity.AreaEntity)
	 */
	public boolean updateAreaInfo(AreaEntity area) throws Exception {
		boolean flag = false;
		try{
			flag = super.updateInfo(area,"Area.updateAreaInfo");
		}catch(Exception ex){
			log.error("修改小区失败",ex);
		}
		return flag;
	}

}
